﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Text;


namespace 李晓霞web
{
    public partial class ChangePassword : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {


        }

       
      

        protected void btn_Click1(object sender, EventArgs e)
        {
            if (this.txtPwd.Text.Trim() == string.Empty || this.txtPwd.Text.Trim() != Session["Password"].ToString())
            {
                this.lblInfo.Text = "请输入正确的旧密码";
            }
            else
            {
                if (this.txtPwdNew.Text.Trim() != this.txtPwdNewAgain.Text.Trim())
                {
                    this.lblInfo.Text = "新密码输入不一致,请重新输入";
                }
                else
                {

                    if (this.txtPwdNew.Text.Trim() != string.Empty)
                    {
                        StringBuilder sb = new StringBuilder(1024);
                        sb.Append("UPDATE  StudentRegister ");
                        sb.Append("SET      Password = @Password ");
                        sb.Append("WHERE UserName='" + Session["UserName"].ToString() + "'");


                        SqlParameter[] pms = new SqlParameter[1];
                        pms[0] = new SqlParameter("@Password", this.txtPwdNew.Text);

                        int intResult = (int)SqlHelper.ExecuteNonQuery(sb.ToString(), pms);
                        this.lblInfo.Text = (intResult < 1) ? "修改失败！" : "成功修改密码";
                    }
                }
            }
        }
    }

}